package com.yuetong.quotation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yuetong.common.annotation.Log;
import com.yuetong.common.core.controller.BaseController;
import com.yuetong.common.core.domain.AjaxResult;
import com.yuetong.common.enums.BusinessType;
import com.yuetong.quotation.domain.YtQuotationInfo;
import com.yuetong.quotation.service.IYtQuotationInfoService;
import com.yuetong.common.utils.poi.ExcelUtil;
import com.yuetong.common.core.page.TableDataInfo;

/**
 * 报价Controller
 * 
 * @author  卓晓君
 * @date 2025-02-11
 */
@RestController
@RequestMapping("/quotation/info")
public class YtQuotationInfoController extends BaseController
{
    @Autowired
    private IYtQuotationInfoService ytQuotationInfoService;

    /**
     * 查询报价列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtQuotationInfo ytQuotationInfo)
    {
        startPage();
        List<YtQuotationInfo> list = ytQuotationInfoService.selectYtQuotationInfoList(ytQuotationInfo);
        return getDataTable(list);
    }

    /**
     * 导出报价列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:info:export')")
    @Log(title = "报价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YtQuotationInfo ytQuotationInfo)
    {
        List<YtQuotationInfo> list = ytQuotationInfoService.selectYtQuotationInfoList(ytQuotationInfo);
        ExcelUtil<YtQuotationInfo> util = new ExcelUtil<YtQuotationInfo>(YtQuotationInfo.class);
        util.exportExcel(response, list, "报价数据");
    }

    /**
     * 获取报价详细信息
     */
    @PreAuthorize("@ss.hasPermi('quotation:info:query')")
    @GetMapping(value = "/{quotationId}")
    public AjaxResult getInfo(@PathVariable("quotationId") Long quotationId)
    {
        return success(ytQuotationInfoService.selectYtQuotationInfoByQuotationId(quotationId));
    }

    /**
     * 新增报价
     */
    @PreAuthorize("@ss.hasPermi('quotation:info:add')")
    @Log(title = "报价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtQuotationInfo ytQuotationInfo)
    {
        return toAjax(ytQuotationInfoService.insertYtQuotationInfo(ytQuotationInfo));
    }

    /**
     * 修改报价
     */
    @PreAuthorize("@ss.hasPermi('quotation:info:edit')")
    @Log(title = "报价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtQuotationInfo ytQuotationInfo)
    {
        return toAjax(ytQuotationInfoService.updateYtQuotationInfo(ytQuotationInfo));
    }

    /**
     * 删除报价
     */
    @PreAuthorize("@ss.hasPermi('quotation:info:remove')")
    @Log(title = "报价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quotationIds}")
    public AjaxResult remove(@PathVariable Long[] quotationIds)
    {
        return toAjax(ytQuotationInfoService.deleteYtQuotationInfoByQuotationIds(quotationIds));
    }
}
